<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //第一种
      let student = {
        id: 1001,
        name: '张贤',
        birthday: 1990 - 6 - 8,
        inSchool: true,
        hobby: ['阅读', '电影', '足球'],
        familyaddress: '广东省 深圳市 宝安区',
        info() {
          let info = `学号：${this.id},名字：${this.name}，生日：${this.birthday}，是否在读：${this.inSchool}，爱好：${this.hobby}，家庭地址：${this.familyaddress}`
          console.log(info)
        },
      }
      //console.log(student.birthday)
      student.info()
      //取值：
      console.log(student.id)
      //修改值：
      student.name = '徐然'
      console.log(student.name)
      //删除属性
      //delete student.name
      console.log(student.name)
      //迭代
      for (let item in student) {
        console.log(student[item])
      }

      function Student() {
        this.id = 1002
        this.name = '韩都'
        this.birthday = 1992 - 5 - 15
        this.inSchool = false
        this.hobby = ['阅读', '电影', '足球']
        this.familyaddress = '广东省 河源市 东源县'
        // this.print = function () {
        //   let info = `学号：${this.id} 名字：${this.name} 生日：${this.birthday} 是否在读：${this.inSchool} 爱好：${this.hobby} 家庭地址：${this.familyaddress}`
        //   console.log(info)
        // }
      }
      let stu = new Student()
      //stu.print()
      //迭代
      for (let item in stu) {
        console.log(stu[item])
      }

      class Student2 {
        id = 1003
        name = '赵政'
        birthday = 1989 - 9 - 12
        hobby = ['阅读', '电影', '足球']
        inSchool = true
        familyaddress = '四川省 内江市 隆昌县'
        print() {
          let info = `学号：${this.id} 名字：${this.name} 生日：${this.birthday} 是否在读：${this.inSchool} 爱好：${this.hobby} 家庭地址：${this.familyaddress}`
          console.log(info)
        }
      }

      let stus = new Student2()
      stus.print()
    </script>
  </body>
</html>
